#include <bits/stdc++.h>
using namespace std;

int a[105],top;
int main()
{
	while(1)
	{
		if (a[top] == 0) break;
		top++;
		cin >> a[top];
	}
	while(top != 0)
	{
		cout << a[--top] << " ";
	}
	return 0;
}
